package com.campus_information_portal.controller;

import com.campus_information_portal.entity.ProjectCondition;
import com.campus_information_portal.service.FinishProjectService;
import com.campus_information_portal.util.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 20155884 王晓阳
 * @className : FinishProjectController
 * @Description
 * @create 2018/05/31 9:58$
 **/
@Controller
@RequestMapping("/finishProject")
@ResponseBody
@CrossOrigin(origins = "*")
public class FinishProjectController {
    @Autowired
    private FinishProjectService finishProjectService;

    //查询状态不为0和2的数据  
    @RequestMapping(value = "/findAgreedProject", method = RequestMethod.GET)
    public Message findAgreedProject(ProjectCondition projectCondition) {
        System.out.println("-findAgreedProject-" + projectCondition.toString());
        ProjectCondition p = new ProjectCondition();
        p.setStuInfoId(projectCondition.getStuInfoId());
        return finishProjectService.findAgreedProject(p);
    }

    //学生结项申请，更新信息applyFinishProject
    @RequestMapping(value = "/updateFinishProject", method = RequestMethod.GET)
    public Message applyFinishProject(ProjectCondition projectCondition) {
        System.out.println("-updateFinishProject-" + projectCondition.toString());
        ProjectCondition p = new ProjectCondition();
        p.setProjectId(projectCondition.getProjectId());
        p.setProjectState(projectCondition.getProjectState());
        p.setProjectConclusion(projectCondition.getProjectConclusion());
        return finishProjectService.updateFinishProject(p);
    }

    //老师端查询所有社会实践信息
    @RequestMapping(value = "/findAgreedProjectByTea", method = RequestMethod.GET)
    public Message findAgreedProjectByTea() {
        System.out.println("-findAgreedProjectByTea-");
        return finishProjectService.findAgreedProjectByTea();
    }

    //根据id查看社会实践--条件查询社会实践
    @RequestMapping(value = "/queryProjectById", method = RequestMethod.GET)
    public Message queryProjectById(ProjectCondition projectCondition) {
        System.out.println("-findAgreedProjectByTea-");
        return finishProjectService.queryProjectById(projectCondition);
    }

    //queryProject
    @RequestMapping(value = "/queryProject", method = RequestMethod.GET)
    public Message queryProject(ProjectCondition projectCondition) {
        System.out.println("-queryProject-"+projectCondition.toString());
        return finishProjectService.queryProject(projectCondition);
    }
}
